/*
 * @LastEditors: yuSeen
 * @LastEditTime: 2022-01-11 12:07:09
 */

import { lazy, ReactNode, Suspense } from "react";
import { RouteObject } from "react-router-dom";
import AppLayout from "../layout/Layout";
const FoundMusic = lazy(() => import("@/views/foundMusic/FoundMusic"));
const Login = lazy(() => import("@/views/login/Login"));
const Friend = lazy(() => import("@/views/friend/Friend"));
const Live = lazy(() => import("@/views/live/Live"));
const Podcast = lazy(() => import("@/views/podcast/Podcast"));
const PriveteFM = lazy(() => import("@/views/priveteFM/PriveteFM"));
const Video = lazy(() => import("@/views/video/Video"));

const Customized = lazy(() => import("@/views/foundMusic/Customized"));
const DailySongs = lazy(() => import("@/views/foundMusic/DailySongs"));
const SongListDetail = lazy(() => import("@/views/songListDetail/SongListDetail"));
const NewMusic = lazy(() => import("@/views/foundMusic/NewMusic"));
const RankList = lazy(() => import("@/views/foundMusic/RankList"));
const Recommend = lazy(() => import("@/views/foundMusic/Recommend"));
const Singer = lazy(() => import("@/views/foundMusic/Singer"));
const SongList = lazy(() => import("@/views/foundMusic/SongList"));

const lazyLoad = (element: ReactNode) => {
  return <Suspense fallback={<></>}>{element}</Suspense>;
};

const routes: RouteObject[] = [
  {
    path: "/",
    element: <AppLayout />,
    children: [
      {
        path: "/foundMusic",
        element: lazyLoad(<FoundMusic />),
        children: [
          {
            path: "/foundMusic/recommend",
            element: lazyLoad(<Recommend />),
          },
          {
            path: "/foundMusic/customized",
            element: lazyLoad(<Customized />),
          },
          {
            path: "/foundMusic/newMusic",
            element: lazyLoad(<NewMusic />),
          },
          {
            path: "/foundMusic/rankList",
            element: lazyLoad(<RankList />),
          },
          {
            path: "/foundMusic/singer",
            element: lazyLoad(<Singer />),
          },
          {
            path: "/foundMusic/songList",
            element: lazyLoad(<SongList />),
          },
        ],
      },
      {
        path: "/dailySongs",
        element: lazyLoad(<DailySongs />),
      },
      {
        path: "/friend",
        element: lazyLoad(<Friend />),
      },
      {
        path: "/live",
        element: lazyLoad(<Live />),
      },
      {
        path: "/podcast",
        element: lazyLoad(<Podcast />),
      },
      {
        path: "/priveteFM",
        element: lazyLoad(<PriveteFM />),
      },
      {
        path: "/songListDetail",
        element: lazyLoad(<SongListDetail />),
      },
      {
        path: "/video",
        element: lazyLoad(<Video />),
      },
    ],
  },
  {
    path: "/login",
    element: lazyLoad(<Login visible={true} />),
  },
];

export default routes;
